#include <memory>
#include <iostream>
using std::auto_ptr;
class MySingle
{
public:
    static MySingle* Instance();
    void SayHello()
    {
        std::cout << "Hello World!" << std::endl;
} private:
    MySingle() {};
    static auto_ptr<MySingle> sm_inst;
};
auto_ptr<MySingle> MySingle::sm_inst;
MySingle* MySingle::Instance()
{
    if(sm_inst.get() == 0)
    {
        auto_ptr<MySingle> tmp(new MySingle);
        sm_inst = tmp;
    }
    return sm_inst.get();
}
int main()
{
    MySingle* pSing = MySingle::Instance();
    if(pSing != 0)
    {
        pSing->SayHello();
    }
    return 0;
}
